package org.java.io;


import org.apache.commons.io.IOUtils;

import java.io.IOException;

/**
 * 文件测试类
 * Created by Administrator on 2016/10/17.
 */
public class FileTest {


    public static void main(String[] args){
        System.out.println(getFileContent("test.xml"));
    }

    /**
     * 获取文件内容
     * @param fileName 文件名称
     * */
    public static String getFileContent(String fileName) {
        String result = "";

        ClassLoader classLoader = new FileTest().getClass().getClassLoader();
        try {
            result = IOUtils.toString(classLoader.getResourceAsStream(fileName));
        } catch (IOException e) {
            e.printStackTrace();
        }

        return result;
    }
}
